import {
    Fog,
    Group,
    MeshBasicMaterial,
    DirectionalLight,
    AmbientLight,
    PointLight,
    Vector3,
    MeshLambertMaterial,
    LineBasicMaterial,
    Color,
    MeshStandardMaterial,
    PlaneGeometry,
    Mesh,
    DoubleSide,
    RepeatWrapping,
    SRGBColorSpace,
    AdditiveBlending,
    VideoTexture,
    NearestFilter,
    BoxGeometry,
    TubeGeometry,
    QuadraticBezierCurve3,
    PointsMaterial,
    Sprite,
    SpriteMaterial,
} from "three";

import {StaticGroup} from "../../model";
import gsap from "gsap";

export class MapSetting {
    scene:any;
    provinceLabel:any;
    otherLabel:any;
    property=[
        'base_am_light','base_direc_light','base_pointLight_1'
    ]
    mesh_property=['base_plane_1','base_plane_2','base_china_line']
    constructor(scene,provinceLabel,otherLabel) {
        this.scene=scene;
        this.provinceLabel=provinceLabel;
        this.otherLabel=otherLabel;
    }

    public initSetting(){
        this.scene.background = new Color(StaticGroup.options.base_scene_bg);
        this.scene.children.forEach(x=>{
            this.property.forEach(key=>{
                if (x.uuid==key){
                    x.color.setStyle(StaticGroup.options[key])
                }
            })
            this.mesh_property.forEach(key=>{
                if (x.uuid==key){
                    x.material.color.setStyle(StaticGroup.options[key]);
                }
            })
        })
        const mapGroup=this.scene.children.find(x=>x.uuid=='mapGroup');
        if (mapGroup) {
            //设置区域颜色,边线
            mapGroup.getObjectByName("china").children.map(xc => {
                xc.children.map(ruc => {
                    ruc.material.color.setStyle(StaticGroup.options.base_area_color);
                })
            })
            mapGroup.getObjectByName("chinaTopLine").children.map(xc => {
                xc.material.color.setStyle(StaticGroup.options.base_bg_line_color);
            })
            //底层颜色
            mapGroup.getObjectByName("chinaBottomLine").children.map(xc => {
                xc.material.color.setStyle(StaticGroup.options.base_china_top_Line);
            })

            // //三维区域颜色配置
            // mapGroup.getObjectByName("areaInfoTop").children.map(xc => {
            //     xc.children.map(ruc => {
            //         ruc.material.color.setStyle(StaticGroup.options.base_province_color);
            //     })
            //     console.log('t',xc.position.z)
            //     //xc.position.z=StaticGroup.options.base_depth*0.1+0.22;
            // })
            mapGroup.getObjectByName("areaInfoLine").children.map(xc => {
                xc.material.color.setStyle(StaticGroup.options.base_area_line_color);
                //xc.position.z=StaticGroup.options.base_depth*0.1+0.23;
            })
        }
        //修改标签属性
        this.provinceLabel.map((item, index) => {
            {
                //背景标签
                let element = item.element.querySelector(".provinces-label-wrap");
                element.style.background=StaticGroup.options.bar_label_bg;
                element.style.borderRadius=`${StaticGroup.options.bar_label_pos.left}px ${StaticGroup.options.bar_label_pos.top}px ${StaticGroup.options.bar_label_pos.right}px ${StaticGroup.options.bar_label_pos.bottom}px`;
            }
            {
                //编号字体
                let element = item.element.querySelector(".provinces-label-wrap .no");
                element.style.color=StaticGroup.options.bar_no_textStyle.color;
                element.style.fontSize=StaticGroup.options.bar_no_textStyle.fontSize;
                element.style.fontWeight=StaticGroup.options.bar_no_textStyle.fontWeight;
                element.style.fontStyle=StaticGroup.options.bar_no_textStyle.fontStyle;
                element.style.fontFamily=StaticGroup.options.bar_no_textStyle.fontFamily;
            }
            {
                //标题
                let element = item.element.querySelector(".provinces-label-wrap .zh");
                element.style.color=StaticGroup.options.bar_name_textStyle.color;
                element.style.fontSize=StaticGroup.options.bar_name_textStyle.fontSize;
                element.style.fontWeight=StaticGroup.options.bar_name_textStyle.fontWeight;
                element.style.fontStyle=StaticGroup.options.bar_name_textStyle.fontStyle;
                element.style.fontFamily=StaticGroup.options.bar_name_textStyle.fontFamily;
            }
            {
                //数值
                let element = item.element.querySelector(".provinces-label-wrap .value");
                element.style.color=StaticGroup.options.bar_num_textStyle.color;
                element.style.fontSize=StaticGroup.options.bar_num_textStyle.fontSize;
                element.style.fontWeight=StaticGroup.options.bar_num_textStyle.fontWeight;
                element.style.fontStyle=StaticGroup.options.bar_num_textStyle.fontStyle;
                element.style.fontFamily=StaticGroup.options.bar_num_textStyle.fontFamily;
            }
            {
                //单位
                let element = item.element.querySelector(".provinces-label-wrap .unit");
                element.style.color=StaticGroup.options.bar_unit_textStyle.color;
                element.style.fontSize=StaticGroup.options.bar_unit_textStyle.fontSize;
                element.style.fontWeight=StaticGroup.options.bar_unit_textStyle.fontWeight;
                element.style.fontStyle=StaticGroup.options.bar_unit_textStyle.fontStyle;
                element.style.fontFamily=StaticGroup.options.bar_unit_textStyle.fontFamily;
            }

        });
        //区域标签
        this.otherLabel.map((item, index) => {
            let element = item.element.querySelector(".other-label");
            element.style.display=StaticGroup.options.area_label_show?"block":"none";
            element.style.background=StaticGroup.options.area_label_bg;
            element.style.borderRadius=`${StaticGroup.options.area_label_pos.left}px ${StaticGroup.options.area_label_pos.top}px ${StaticGroup.options.area_label_pos.right}px ${StaticGroup.options.area_label_pos.bottom}px`;
            element.style.color=StaticGroup.options.area_label_textStyle.color;
            element.style.fontSize=StaticGroup.options.area_label_textStyle.fontSize;
            element.style.fontWeight=StaticGroup.options.area_label_textStyle.fontWeight;
            element.style.fontStyle=StaticGroup.options.area_label_textStyle.fontStyle;
            element.style.fontFamily=StaticGroup.options.area_label_textStyle.fontFamily;
            item.position.z=StaticGroup.options.area_label_z*0.1;
        });
    }
}